﻿
using System.Threading;
using jSLCore.Service.Workflow;

namespace jSLApp.Web
{
    using System.Linq;
    using System.ServiceModel.DomainServices.Hosting;
    using Microsoft.ServiceModel.DomainServices.LinqToSql;
    using Workflow;


    // Implements application logic using the DB context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    [EnableClientAccess()]
    public class MainDomainService : LinqToSqlDomainService<DB>
    {
        public IQueryable<User> GetUsers()
        {
            return this.DataContext.Users;
        }

        public User GetFirstUser()
        {
            return this.DataContext.Users.First();
        }

        public void SendFeedback(string text)
        {
            MainServiceEx.SendMailToAllSuperVisors(DataContext, text);
        }

        public void WaitOnServer(int seconds)
        {
            Thread.Sleep(seconds);
        }

        public double Devide(double a,double b)
        {
            if(Equals(b, 0d))jWorkflowException.ThrowNewDomainException("Can not devide on zero");
            return a/b;
        }
    }
}


